package com.macrohard.admin.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.macrohard.mapper.domain.Address;
import com.macrohard.admin.service.AddressService;
import com.macrohard.mapper.mapper.AddressMapper;
import lombok.RequiredArgsConstructor;
import org.apache.commons.math3.analysis.function.Add;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 27371
* @description 针对表【address】的数据库操作Service实现
* @createDate 2022-07-14 12:32:00
*/
@Service
@RequiredArgsConstructor
public class AddressServiceImpl extends ServiceImpl<AddressMapper, Address>
    implements AddressService{
		private final AddressMapper addressMapper;

		@Cacheable("address-names")
		public List<Address> listAllNameAndId() {
			return addressMapper.getNameAndId();
		}

		@CachePut("address-names")
		public int add(Address address) {
			return addressMapper.insert(address);
		}

		@CachePut("address-names")
		public int modify(Address address) {
			return addressMapper.updateById(address);
		}

		@CachePut("address-names")
		public int removeOne(int id) {
			return addressMapper.deleteById(id);
		}
}




